Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: hotosm/fAIr
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: develop
Choose a base ref
...
head repository: nifedara/fAIr
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: tests/feedback-model
Choose a head ref
Can’t automatically merge. Don’t worry, you can still create the pull request.
  • 14 commits
  • 3 files changed
  • 1 contributor

Commits on Mar 29, 2024

  1. added login model test

    nifedara committed Mar 29, 2024
    Copy the full SHA
    556c162 View commit details

Commits on Apr 2, 2024

  1. added factory boy

    nifedara committed Apr 2, 2024
    Copy the full SHA
    1a9b419 View commit details
  2. added dataset creation test

    nifedara committed Apr 2, 2024
    Copy the full SHA
    7a47d11 View commit details
  3. Copy the full SHA
    4aba08c View commit details
  4. added aoi factory

    nifedara committed Apr 2, 2024
    Copy the full SHA
    f8d78da View commit details
  5. added test set up

    nifedara committed Apr 2, 2024
    Copy the full SHA
    094d395 View commit details
  6. added Label factory

    nifedara committed Apr 2, 2024
    Copy the full SHA
    57fbc02 View commit details
  7. added label creation test

    nifedara committed Apr 2, 2024
    Copy the full SHA
    e0d5574 View commit details
  8. added Model factory

    nifedara committed Apr 2, 2024
    Copy the full SHA
    b8672fc View commit details
  9. added Model creation test

    nifedara committed Apr 2, 2024
    Copy the full SHA
    93965fd View commit details
  10. added training factory

    nifedara committed Apr 2, 2024
    Copy the full SHA
    e1cb21a View commit details
  11. added training test

    nifedara committed Apr 2, 2024
    Copy the full SHA
    af30aca View commit details
  12. added Feedback factory

    nifedara committed Apr 2, 2024
    Copy the full SHA
    450db06 View commit details
  13. added feeback creation test

    nifedara committed Apr 2, 2024
    Copy the full SHA
    4b7c728 View commit details
Showing with 143 additions and 0 deletions.
  1. +76 −0 backend/tests/factories.py
  2. +55 −0 backend/tests/test_core_model.py
  3. +12 −0 backend/tests/test_login_model.py
76 changes: 76 additions & 0 deletions backend/tests/factories.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
import factory

from login.models import OsmUser
from core.models import Dataset, AOI, Label, Model, Training, Feedback


class OsmUserFactory(factory.django.DjangoModelFactory):
class Meta:
model = OsmUser

username = "Test User"
osm_id = 123456


class DatasetFactory(factory.django.DjangoModelFactory):
class Meta:
model = Dataset

name = "Test Dataset"
created_by = factory.SubFactory(OsmUserFactory)
status = -1


class AoiFactory(factory.django.DjangoModelFactory):
class Meta:
model = AOI

geom = "POLYGON ((0 0, 0 1, 1 1, 1 0, 0 0))"
dataset = factory.SubFactory(DatasetFactory)
label_status = -1


class LabelFactory(factory.django.DjangoModelFactory):

class Meta:
model = Label

aoi = factory.SubFactory(AoiFactory)
geom = "POLYGON ((0 0, 0 1, 1 1, 1 0, 0 0))"


class ModelFactory(factory.django.DjangoModelFactory):

class Meta:
model = Model

dataset = factory.SubFactory(DatasetFactory)
name = "Test Model"
created_by = factory.SubFactory(OsmUserFactory)
status = -1


class TrainingFactory(factory.django.DjangoModelFactory):

class Meta:
model = Training

model = factory.SubFactory(ModelFactory)
status = "SUBMITTED"
zoom_level = [20, 21]
created_by = factory.SubFactory(OsmUserFactory)
epochs = 3
batch_size = 24


class FeedbackFactory(factory.django.DjangoModelFactory):

class Meta:
model = Feedback

geom = "POLYGON ((0 0, 0 1, 1 1, 1 0, 0 0))"
training = factory.SubFactory(TrainingFactory)
zoom_level = 19
feedback_type = "TP"
user = factory.SubFactory(OsmUserFactory)
source_imagery = "https://test_data/hotosm/fAIr/"
55 changes: 55 additions & 0 deletions backend/tests/test_core_model.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
from django.test import TestCase

from .factories import (
DatasetFactory,
OsmUserFactory,
AoiFactory,
LabelFactory,
ModelFactory,
TrainingFactory,
FeedbackFactory,
)


class TestCoreModels(TestCase):

def setUp(self):
self.user = OsmUserFactory(username="Test User 2", osm_id=123)
self.dataset = DatasetFactory(created_by=self.user)
self.aoi = AoiFactory(dataset=self.dataset)
self.label = LabelFactory(aoi=self.aoi)
self.model = ModelFactory(dataset=self.dataset, created_by=self.user)
self.training = TrainingFactory(model=self.model, created_by=self.user)
self.feedback = FeedbackFactory(training=self.training, user=self.user)

def test_dataset_creation(self):
self.assertEqual(self.dataset.name, "Test Dataset")
self.assertEqual(self.dataset.created_by, self.user)

def test_aoi_creation(self):
self.assertEqual(self.aoi.dataset, self.dataset)
self.assertEqual(self.aoi.label_status, -1)

def test_label_creation(self):
self.assertEqual(self.label.aoi, self.aoi)

def test_model_creation(self):
self.assertEqual(self.model.name, "Test Model")
self.assertEqual(self.model.dataset, self.dataset)
self.assertEqual(self.model.created_by, self.user)
self.assertEqual(self.model.status, -1)

def test_training_creation(self):
self.assertEqual(self.training.model, self.model)
self.assertEqual(self.training.status, "SUBMITTED")
self.assertEqual(self.training.zoom_level, [20, 21])
self.assertEqual(self.training.created_by, self.user)
self.assertEqual(self.training.epochs, 3)
self.assertEqual(self.training.batch_size, 24)

def test_feedback_creation(self):
self.assertEqual(self.feedback.training, self.training)
self.assertEqual(self.feedback.zoom_level, 19)
self.assertEqual(self.feedback.feedback_type, "TP")
self.assertEqual(self.feedback.user, self.user)
self.assertEqual(self.feedback.source_imagery, "https://test_data/hotosm/fAIr/")
12 changes: 12 additions & 0 deletions backend/tests/test_login_model.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from django.test import TestCase

from .factories import OsmUserFactory


class TestLoginModels(TestCase):

def test_OsmUser_creation(self):
osm_user = OsmUserFactory()

self.assertEqual(str(osm_user), "Test User")
self.assertEqual(osm_user.osm_id, 123456)