Beispiel #1
0
 def test_get_wrong_id(self, testclient, fake_device_event_definition):
     expected = expect_detail(404, "Not found.")
     pp = {
         "device_id": fake_device_event_definition.device.id,
         "event_def_id": 123456
     }
     testclient.get_request_test_helper(expected, path_params=pp)
Beispiel #2
0
 def test_get_no_auth(self, testclient, fake_device_event_definition):
     exp = expect_detail(401,
                         "Authentication credentials were not provided.")
     pp = {
         "device_id": fake_device_event_definition.device.id,
         "event_def_id": fake_device_event_definition.id
     }
     testclient.get_request_test_helper(exp, path_params=pp)
Beispiel #3
0
    def test_get_by_reference(self, testclient, fredbloggs):
        device = DeviceFactory()
        event_def_1 = DeviceEventDefinitionFactory(device=device,
                                                   product=None,
                                                   ref="abcde")
        event_def_2 = DeviceEventDefinitionFactory(device=device,
                                                   product=None,
                                                   ref="bcdef")

        expected = expect_detail(404, "Not found.")
        pp = {"device_id": device.id}
        qp = {"ref": "abcde"}
        testclient.get_request_test_helper(expected,
                                           path_params=pp,
                                           query_params=qp)
        group = OrganizationFactory()
        device.orgs.add(group)
        device.save()
        # fredbloggs.orgs.add(group)
        fredbloggs.add_org(group)
        fredbloggs.save()

        data_1 = EventDefinitionSerializer(event_def_1).data
        data_2 = EventDefinitionSerializer(event_def_2).data

        expected = expect_list(200, [data_1])
        pp = {"device_id": device.id}
        qp = {"ref": "abcde"}
        testclient.get_request_test_helper(expected,
                                           path_params=pp,
                                           query_params=qp)

        expected = expect_list(200, [data_2])
        qp = {"ref": "*ef"}
        testclient.get_request_test_helper(expected,
                                           path_params=pp,
                                           query_params=qp)

        expected = expect_list(200, [data_2])
        qp = {"ref": "bcdef"}
        testclient.get_request_test_helper(expected,
                                           path_params=pp,
                                           query_params=qp)

        expected = expect_list(200, [data_1, data_2])
        qp = {"ref": "*cd*"}
        testclient.get_request_test_helper(expected,
                                           path_params=pp,
                                           query_params=qp)

        expected = expect_list(200, [])
        qp = {"ref": "xyz"}
        testclient.get_request_test_helper(expected,
                                           path_params=pp,
                                           query_params=qp)
Beispiel #4
0
    def test_get_deleted(self, testclient, fake_device_event_definition):
        fake_device_event_definition.deleted = True
        fake_device_event_definition.save()
        expected = expect_detail(404, "Not found.")
        pp = {
            "device_id": fake_device_event_definition.device.id,
            "event_def_id": fake_device_event_definition.id
        }
        testclient.get_request_test_helper(expected, path_params=pp)

        # Make sure it's still there, just marked as deleted
        event_defs = EventDefinition.objects.all()
        assert event_defs
        assert event_defs[0].deleted == True