Ejemplo n.º 1
0
 def setUp(self):
     ClientTest.setUp(self)
     self.client.login(username='******', password='******')
     self.source_id = Source.objects.get(name='Labelset 2keys').pk
Ejemplo n.º 2
0
    def setUp(self):
        ClientTest.setUp(self)
        self.client.login(username='******', password='******')
        self.source_id = Source.objects.get(name='Labelset 2keys').pk

        # Files to upload.
        self.image_filenames = [
            os.path.join('2keys', 'cool_001_2011-05-28.png'),
            os.path.join('2keys', 'cool_001_2012-05-28.png'),
            os.path.join('2keys', 'cool_002_2011-05-28.png'),
        ]

        self.annotation_file_contents_with_labels = (
            "cool; 001; 2011; 200; 300; Scarlet\n"
            "cool; 001; 2011; 50; 250; Lime\n"
            "cool; 001; 2011; 10; 10; Turq\n"
            "\n"
            "cool; 001; 2012; 1; 1; UMarine\n"
            "cool; 001; 2012; 400; 400; Lime\n"
            "\n"
            "cool; 002; 2011; 160; 40; Turq\n"
            "\n"
            "will_not_be_uploaded; 025; 2004; 1465; 797; UMarine\n"
        )
        self.annotation_file_contents_without_labels = (
            "cool; 001; 2011; 200; 300\n"
            "cool; 001; 2011; 50; 250\n"
            "cool; 001; 2011; 10; 10\n"
            "\n"
            "cool; 001; 2012; 1; 1\n"
            "cool; 001; 2012; 400; 400\n"
            "\n"
            "cool; 002; 2011; 160; 40\n"
            "\n"
            "will_not_be_uploaded; 025; 2004; 1465; 797\n"
        )

        # Number of annotations that should be recognized by the annotation
        # file check.  Note that the annotation file check does not know
        # what image files are actually going to be uploaded; so if the
        # annotation file contains annotations for image A, then it would
        # report an annotation count for image A even if A isn't uploaded.
        self.expected_annotations_per_image = {
            'cool;001;2011': 3,
            'cool;001;2012': 2,
            'cool;002;2011': 1,
            'will_not_be_uploaded;025;2004': 1,
        }

        # The annotations that should actually be created after the upload
        # completes.
        self.expected_annotations = {
            'cool_001_2011-05-28.png': set([
                (200, 300, 'Scarlet'),
                (50, 250, 'Lime'),
                (10, 10, 'Turq'),
            ]),
            'cool_001_2012-05-28.png': set([
                (1, 1, 'UMarine'),
                (400, 400, 'Lime'),
            ]),
            'cool_002_2011-05-28.png': set([
                (160, 40, 'Turq'),
            ]),
        }

        # Same as expected_annotations, but for the points-only option.
        self.expected_points = {
            'cool_001_2011-05-28.png': set([
                (200, 300),
                (50, 250),
                (10, 10),
            ]),
            'cool_001_2012-05-28.png': set([
                (1, 1),
                (400, 400),
            ]),
            'cool_002_2011-05-28.png': set([
                (160, 40),
            ]),
        }