Skip to content

Unit testing#96

Open
nam20485 wants to merge 12 commits intostagingfrom
unit-testing
Open

Unit testing#96
nam20485 wants to merge 12 commits intostagingfrom
unit-testing

Conversation

@nam20485
Copy link
Contributor

  • add pytest to project
  • use pytest for unit testing
  • add some basic unit tests

@nam20485 nam20485 self-assigned this Oct 27, 2018
Copy link
Member

@bhgrant8 bhgrant8 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nam20485, started testing this today, not sure if something in my environment or not but:

on ./bin/build.sh -d I am running into the following:

Reading package lists...
E: Unable to correct problems, you have held broken packages.
ERROR: Service 'db_development' failed to build: The command '/bin/sh -c apt-get update   && apt-get install -qqy --no-install-recommends     postgis     postgresql-9.6-postgis-2.4     postgresql-9.6-postgis-2.4-scripts     postgresql-9.6-postgis-scripts     postgresql-9.6-pgrouting   && apt-get clean' returned a non-zero code: 100

I originally was able to pull the repo and run tests but ran into 2 failing ones:

============================================ test session starts =============================================
platform linux -- Python 3.6.5, pytest-4.0.1, py-1.7.0, pluggy-0.8.0
Django settings: dead_songs.settings (from ini file)
rootdir: /code, inifile: pytest.ini
plugins: xdist-1.24.1, forked-0.2, django-3.4.4
gw0 [13] / gw1 [13] / gw2 [13] / gw3 [13]
scheduling tests via LoadScheduling
..........F.F                                                                                          [100%]
================================================== FAILURES ==================================================
_________________________________ APIEndpointsTestCase.test_detail_responses _________________________________
[gw2] linux -- Python 3.6.5 /usr/local/bin/python

self = <api.tests.tests.APIEndpointsTestCase testMethod=test_detail_responses>

    def test_detail_responses(self):
        for endpoint in self.datasets:
>           response = self.client.get('/api/'+endpoint+'/1/')

api/tests/tests.py:59: 
_ _ _ _ _ _ _ _ _ _ _ _

and:

__________________________________ APIEndpointsTestCase.test_list_responses __________________________________
[gw0] linux -- Python 3.6.5 /usr/local/bin/python

self = <api.tests.tests.APIEndpointsTestCase testMethod=test_list_responses>

    def test_list_responses(self):
        for endpoint in self.datasets:
>           response = self.client.get('/api/'+endpoint+'/')

api/tests/tests.py:55: 
_ _ _ _ _ _ _ _ _ _ _ _ _ 

Then i ran a docker system prune as I have nothing else in docker running right now, figured I'd nuke the system and confirm any issues.

Began the first 2 steps of the build for the sample:

First cd into the root directory of your clone of the repo and run the command cp env.sample .env

Build the development containers using the command: ./bin/build.sh -d

This is where I ran into above error.

Here is the full log:

UA-C02T8D1VGTFM:backend-examplar-2018 brian.grant$ ./bin/build.sh -d
Building db_development
Step 1/6 : FROM postgres:9.6
 ---> 12fd61c0e7e1
Step 2/6 : LABEL maintainer="M. Edward (Ed) Borasky <znmeb@znmeb.net>"
 ---> Running in 283c0ee9f727
Removing intermediate container 283c0ee9f727
 ---> c6b3412465c0
Step 3/6 : RUN apt-get update   && apt-get install -qqy --no-install-recommends     postgis     postgresql-9.6-postgis-2.4     postgresql-9.6-postgis-2.4-scripts     postgresql-9.6-postgis-scripts     postgresql-9.6-pgrouting   && apt-get clean
 ---> Running in 387f68215f48
Ign:1 http://deb.debian.org/debian stretch InRelease
Get:2 http://security.debian.org/debian-security stretch/updates InRelease [94.3 kB]
Get:3 http://deb.debian.org/debian stretch-updates InRelease [91.0 kB]
Get:4 http://deb.debian.org/debian stretch Release [118 kB]
Get:5 http://deb.debian.org/debian stretch Release.gpg [2,434 B]
Get:6 http://security.debian.org/debian-security stretch/updates/main amd64 Packages [460 kB]
Get:7 http://deb.debian.org/debian stretch-updates/main amd64 Packages [5,152 B]
Get:8 http://apt.postgresql.org/pub/repos/apt stretch-pgdg InRelease [46.3 kB]
Get:9 http://deb.debian.org/debian stretch/main amd64 Packages [7,089 kB]
Get:10 http://apt.postgresql.org/pub/repos/apt stretch-pgdg/9.6 amd64 Packages [1,850 B]
Get:11 http://apt.postgresql.org/pub/repos/apt stretch-pgdg/main amd64 Packages [164 kB]
Fetched 8,072 kB in 2s (2,880 kB/s)
Reading package lists...
E: Unable to correct problems, you have held broken packages.
ERROR: Service 'db_development' failed to build: The command '/bin/sh -c apt-get update   && apt-get install -qqy --no-install-recommends     postgis     postgresql-9.6-postgis-2.4     postgresql-9.6-postgis-2.4-scripts     postgresql-9.6-postgis-scripts     postgresql-9.6-pgrouting   && apt-get clean' returned a non-zero code: 100

So appears to be on the development db startup. maybe something has changed with a package there preventing a new build?

@nam20485
Copy link
Contributor Author

@bhgrant8 thanks for the debug info.

The issue you encountered has been resolved- there was a redundant package specified for apt get install that was causing a conflict with another package that was actually needed.

postgresql-9.6-postgis-scripts is redundant, and not needed since postgresql-9.6-postgis-2.4-scripts is specified, especially since it was causing a dependency conflict with the needed package. I removed the redundant package and everything builds successfully now.

Please update your working copy and try again.

(Adding @znmeb since he helped create the postgres/postgis installation steps. We may need to check this on other repos that install postgis)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants