Customer contacts added into statistics info
Customer contacts sends to stats collector, if provided Closes-Bug: 1396197 Change-Id: I4682776e7fb5b3a45291cda146b1cc659e39c04e
This commit is contained in:
parent
b17a26e41e
commit
14a349708e
|
@ -184,11 +184,16 @@ class InstallationInfo(object):
|
|||
try:
|
||||
stat_settings = MasterNodeSettings.get_one(). \
|
||||
settings.get("statistics", {})
|
||||
|
||||
return {
|
||||
result = {
|
||||
"contact_info_provided":
|
||||
stat_settings.get("user_choice_saved", {}).get("value", False)
|
||||
and stat_settings.get("send_user_info", {}).get("value", False)
|
||||
}
|
||||
if result["contact_info_provided"]:
|
||||
result["name"] = stat_settings.get("name", {}).get("value")
|
||||
result["email"] = stat_settings.get("email", {}).get("value")
|
||||
result["company"] = stat_settings.get("company", {}).\
|
||||
get("value")
|
||||
return result
|
||||
except AttributeError:
|
||||
return {"contact_info_provided": False}
|
||||
|
|
|
@ -426,7 +426,7 @@ class TestMasterNodeSettingsHandler(BaseIntegrationTest):
|
|||
self.assertEqual(StatsSender().must_send_stats(), False)
|
||||
|
||||
def test_user_contacts_info_disabled_while_not_confirmed_by_user(self):
|
||||
self.assertEqual(
|
||||
self.assertDictEqual(
|
||||
InstallationInfo().get_installation_info()['user_information'],
|
||||
{'contact_info_provided': False})
|
||||
|
||||
|
@ -445,7 +445,7 @@ class TestMasterNodeSettingsHandler(BaseIntegrationTest):
|
|||
params=jsonutils.dumps(data)
|
||||
)
|
||||
self.assertEqual(200, resp.status_code)
|
||||
self.assertEqual(
|
||||
self.assertDictEqual(
|
||||
InstallationInfo().get_installation_info()['user_information'],
|
||||
{'contact_info_provided': False})
|
||||
|
||||
|
@ -460,15 +460,58 @@ class TestMasterNodeSettingsHandler(BaseIntegrationTest):
|
|||
data["settings"]["statistics"]["user_choice_saved"]["value"] = True
|
||||
data["settings"]["statistics"]["send_user_info"]["value"] = \
|
||||
True
|
||||
name = "user"
|
||||
email = "u@e.mail"
|
||||
company = "user company"
|
||||
data["settings"]["statistics"]["name"]["value"] = name
|
||||
data["settings"]["statistics"]["email"]["value"] = email
|
||||
data["settings"]["statistics"]["company"]["value"] = company
|
||||
resp = self.app.put(
|
||||
reverse("MasterNodeSettingsHandler"),
|
||||
headers=self.default_headers,
|
||||
params=jsonutils.dumps(data)
|
||||
)
|
||||
self.assertEqual(200, resp.status_code)
|
||||
self.assertEqual(
|
||||
self.assertDictEqual(
|
||||
InstallationInfo().get_installation_info()['user_information'],
|
||||
{'contact_info_provided': True})
|
||||
{
|
||||
'contact_info_provided': True,
|
||||
'name': name,
|
||||
'email': email,
|
||||
'company': company
|
||||
}
|
||||
)
|
||||
|
||||
def test_partial_user_contacts_info(self):
|
||||
resp = self.app.get(
|
||||
reverse("MasterNodeSettingsHandler"),
|
||||
headers=self.default_headers)
|
||||
self.assertEqual(200, resp.status_code)
|
||||
data = resp.json_body
|
||||
|
||||
# emulate user enabled contact info sending to support team
|
||||
data["settings"]["statistics"]["user_choice_saved"]["value"] = True
|
||||
data["settings"]["statistics"]["send_user_info"]["value"] = \
|
||||
True
|
||||
name = "user"
|
||||
email = "u@e.mail"
|
||||
data["settings"]["statistics"]["name"]["value"] = name
|
||||
data["settings"]["statistics"]["email"]["value"] = email
|
||||
resp = self.app.put(
|
||||
reverse("MasterNodeSettingsHandler"),
|
||||
headers=self.default_headers,
|
||||
params=jsonutils.dumps(data)
|
||||
)
|
||||
self.assertEqual(200, resp.status_code)
|
||||
self.assertDictEqual(
|
||||
InstallationInfo().get_installation_info()['user_information'],
|
||||
{
|
||||
'contact_info_provided': True,
|
||||
'name': name,
|
||||
'email': email,
|
||||
'company': ''
|
||||
}
|
||||
)
|
||||
|
||||
def test_user_contacts_info_broken(self):
|
||||
settings_from_db = objects.MasterNodeSettings.get_one()
|
||||
|
@ -477,7 +520,7 @@ class TestMasterNodeSettingsHandler(BaseIntegrationTest):
|
|||
settings_from_db.settings = settings
|
||||
self.db.commit()
|
||||
|
||||
self.assertEqual(
|
||||
self.assertDictEqual(
|
||||
InstallationInfo().get_installation_info()['user_information'],
|
||||
{'contact_info_provided': False})
|
||||
|
||||
|
@ -486,7 +529,7 @@ class TestMasterNodeSettingsHandler(BaseIntegrationTest):
|
|||
self.db.delete(settings_from_db)
|
||||
self.db.commit()
|
||||
|
||||
self.assertEqual(
|
||||
self.assertDictEqual(
|
||||
InstallationInfo().get_installation_info()['user_information'],
|
||||
{'contact_info_provided': False})
|
||||
self.assertEqual(
|
||||
|
|
Loading…
Reference in New Issue