Example #1
0
    def test_map_for_scenario(self, mock_choice):
        users_ = []
        tenants = {}

        for i in range(2):
            tenants[str(i)] = {"name": str(i)}
            for j in range(3):
                users_.append({
                    "id": "%s_%s" % (i, j),
                    "tenant_id": str(i),
                    "endpoint": "endpoint"
                })

        context = {
            "admin": mock.MagicMock(),
            "users": users_,
            "tenants": tenants,
            "some_random_key": {
                "nested": mock.MagicMock(),
                "one_more": 10
            }
        }
        chosen_tenant = context["tenants"][context["users"][1]["tenant_id"]]
        expected_context = {
            "admin": context["admin"],
            "user": context["users"][1],
            "tenant": chosen_tenant,
            "some_random_key": context["some_random_key"]
        }

        self.assertEqual(expected_context,
                         users.UserContextMixin().map_for_scenario(context))
Example #2
0
 def setUp(self):
     super(self.__class__, self).setUp()
     self.mixin = users.UserContextMixin()
     self.mixin.context = {
         "config": {
             "users": {
                 "user_choice_method": "random",
             },
         },
     }