def setUp(self): self.user1 = UserFactory.build() self.user1.save() self.client.login(username=self.user1.username, password=self.user1.password) self.tempfile = tempfile.NamedTemporaryFile() self.document = SimpleUploadedFile(self.tempfile.name, b'some example data for our file') self.imagenote = ImageNote.objects.create(lat=52, lon=-113 )
def setUp(self): self.owner = UserFactory.build() self.owner.save() self.tempfile = tempfile.NamedTemporaryFile() self.document = SimpleUploadedFile(self.tempfile.name, b'some example data for our file') self.project = Project.objects.create(path="testpath",url=self.document, uploadurl='http://gpap.trailstewards.com/userprojects') self.project.save() self.tag = Tag.objects.create(path="testpath1",url=self.document ) self.tag.save() self.basemap = Basemap.objects.create(path="testpath1",url=self.document) self.basemap.save() self.spatialitedb = Spatialitedbs.objects.create(path="testpath1",url=self.document, uploadurl='http://webmap.geoanalytic.com/download/Trails/Alberta.sqlite', visible=["sites","atv"]) self.spatialitedb.save() self.location = Point(-114.38, 52.12) self.otherfile = Otherfiles.objects.create(path="testpath1",url=self.document, location=self.location) self.otherfile.save() self.profile1 = Profile.objects.create(name='testprofile', description='a profile for testing', project=self.project, tags=self.tag) self.profile1.basemaps.add(self.basemap) self.profile1.spatialitedbs.add(self.spatialitedb) self.profile1.otherfiles.add(self.otherfile) self.profile1.save() self.profile2 = Profile.objects.create(name='testprofile2', description='a second profile for testing', project=self.project, tags=self.tag) self.profile2.basemaps.add(self.basemap) self.profile2.spatialitedbs.add(self.spatialitedb) self.profile2.save() self.profileset = ProfileSet(owner=self.owner) self.profileset.save() self.profileset.profiles.add(self.profile1) self.profileset.profiles.add(self.profile2)
def test_clean_username(self): # A user with proto_user params does not exist yet. proto_user = UserFactory.build() form = UserCreationForm( { "username": proto_user.username, "password1": proto_user._password, "password2": proto_user._password, } ) assert form.is_valid() assert form.clean_username() == proto_user.username # Creating a user. form.save() # The user with proto_user params already exists, # hence cannot be created. form = UserCreationForm( { "username": proto_user.username, "password1": proto_user._password, "password2": proto_user._password, } ) assert not form.is_valid() assert len(form.errors) == 1 assert "username" in form.errors
def setUp(self): self.user1 = UserFactory.build() self.user1.save() self.client.login(username=self.user1.username, password=self.user1.password) self.tempfile = tempfile.NamedTemporaryFile() self.document = SimpleUploadedFile(self.tempfile.name, b'some example data for our file')
def setUp(self): self.timestamp_start = datetime.datetime.now(tz=datetime.timezone.utc) self.owner = UserFactory.build() self.owner.save() self.linestring = LineString(Point(-114.38, 52.12),Point(-114.381, 52.123),Point(-114.389, 52.123),Point(-114.386, 52.119)) self.timestamp_end = datetime.datetime.now(tz=datetime.timezone.utc) self.trackfeature = TrackFeature.objects.create(linestring=self.linestring, owner=self.owner, timestamp_start=self.timestamp_start, timestamp_end=self.timestamp_end, text='some test text')
def setUp(self): self.owner = UserFactory.build() self.owner.save() self.location = Point(-114.38, 52.12) self.form = '{"sectionname":"Image Note","sectiondescription":"note with image","forms":[{"formname":"image note","formitems":[{"key":"description","islabel":"true","value":"cutline 1","type":"string","mandatory":"no"},{"key":"pictures of the environment around the note","value":"11;12","type":"pictures"}]}]}' self.note = Note.objects.create(location=self.location, lat=52.12, lon=-114.38, altitude=1105.5, timestamp=datetime.datetime.now(tz=datetime.timezone.utc), owner=self.owner, form=self.form, description='POI', text='Test text here')
def setUp(self): self.owner = UserFactory.build() self.owner.save() self.location = Point(-114.38, 52.12) self.form = '{"sectionname":"Image Note","sectiondescription":"note with image","forms":[{"formname":"image note","formitems":[{"key":"description","islabel":"true","value":"cutline 1","type":"string","mandatory":"no"},{"key":"pictures of the environment around the note","value":"11;12","type":"pictures"}]}]}' self.note = Note.objects.create(location=self.location, lat=52.12, lon=-114.38, altitude=1105.5, timestamp=datetime.datetime.now(tz=datetime.timezone.utc), owner=self.owner, form=self.form, description='POI', text='Image note') self.tempfile = tempfile.NamedTemporaryFile() self.document = SimpleUploadedFile(self.tempfile.name, b'some example data for our file') self.imagenote = ImageNote.objects.create(location=self.location, lat=52.12, lon=-114 - 38, altitude=1105.5, azimuth=328.12, timestamp=datetime.datetime.now(tz=datetime.timezone.utc), owner=self.owner, image=self.document, note=self.note)
def setUp(self): self.tempfile = tempfile.NamedTemporaryFile() self.document = SimpleUploadedFile(self.tempfile.name, b'some example data for our file') self.project = Project.objects.create( path="testpath", url=self.document, uploadurl='http://gpap.trailstewards.com/userprojects') self.tag = Tag.objects.create(path="testpath1", url=self.document) self.basemap = Basemap.objects.create(path="testpath1", url=self.document) self.spatialitedb = Spatialitedbs.objects.create( path="testpath1", url=self.document, uploadurl= 'http://webmap.geoanalytic.com/download/Trails/Alberta.sqlite', visible=["sites", "atv"]) self.otherfile = Otherfiles.objects.create(path="testpath1", url=self.document) self.profile1 = Profile.objects.create(name="test", description="test profile", color="#FFFFFF", active=True, sdcardPath="MAINSTORAGE", mapView="52.0,-110.5,11", project=self.project, tags=self.tag) self.profile1.basemaps.add(self.basemap) self.profile1.spatialitedbs.add(self.spatialitedb) self.profile1.otherfiles.add(self.otherfile) self.profile2 = Profile.objects.create(name="test2", description="test profile2", color="#FFEFF", active=False, sdcardPath="MAINSTORAGE", mapView="52.0,-110.5,11", project=self.project, tags=self.tag) self.profile2.basemaps.add(self.basemap) self.profile2.spatialitedbs.add(self.spatialitedb) self.user1 = UserFactory.build() self.user1.save() self.client.login(username=self.user1.username, password=self.user1.password)
def setUp(self): self.owner = UserFactory.build() self.owner.save() self.tempfile = tempfile.NamedTemporaryFile() self.description = 'a temporary file for testing' self.userproject = UserProject(owner=self.owner, document=self.tempfile, description=self.description)
def user() -> settings.AUTH_USER_MODEL: return UserFactory()