Skip to content

Commit 4dcdf52

Browse files
authored
Merge pull request #73 from appsembler/css
return CSS as dictionary
2 parents 61130f7 + 7623ece commit 4dcdf52

File tree

3 files changed

+15
-35
lines changed

3 files changed

+15
-35
lines changed

setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ def read(fname):
88

99
setup(
1010
name='site-configuration-client',
11-
version='0.1.9',
11+
version='0.1.10',
1212
description='Python client library for Site Configuration API',
1313
long_description=read('README.rst'),
1414
classifiers=[

site_config_client/openedx/adapter.py

+3-14
Original file line numberDiff line numberDiff line change
@@ -42,20 +42,9 @@ def get_value_of_type(self, config_type, name, default):
4242
type_configs = all_configs[config_type]
4343
return type_configs.get(name, default)
4444

45-
def get_amc_v1_theme_css_variables(self):
45+
def get_css_variables_dict(self):
4646
"""
47-
Returns an Open edX AMC v1 theme compatible sass variables.
48-
49-
Note: This function assumes that all variables are compatible with v1 theme.
47+
Get a variable_name:value dictionary of CSS variables.
5048
"""
5149
config = self.get_backend_configs()['configuration']
52-
53-
# Imitates the values in edX's SiteConfiguration sass_variables
54-
openedx_theme_compatible_css_vars = [
55-
# Note: The usual AMC produced format is key --> [value, default]
56-
# The second value is mostly unused by Open edX can be
57-
# set as [value, default].
58-
[key, val]
59-
for key, val in config[self.TYPE_CSS].items()
60-
]
61-
return openedx_theme_compatible_css_vars
50+
return config[self.TYPE_CSS]

tests/test_adapter.py

+11-20
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
"""
44
import pytest
55
from unittest.mock import Mock
6-
from collections import OrderedDict
76

87

98
CONFIGS = {
@@ -12,16 +11,11 @@
1211
},
1312
"status": "live",
1413
"configuration": {
15-
"css": OrderedDict(
16-
# Just like a normal dict, but makes tests less flaky
17-
(
18-
("selected_font", ["lato", "lato"]),
19-
("text_color", ["#0a0a0a", "#0a0a0a"]),
20-
("header_logo_height", ["110", "110"]),
21-
("header_buttons_color", ["#164be0", "#164be0"]),
22-
("header_font_size", ["17", "17"]),
23-
)
24-
),
14+
"css": {
15+
"selected_font": "lato",
16+
"text_color": "#0a0a0a",
17+
"header_logo_height": "110",
18+
},
2519
"page": {
2620
"course-card": "course-tile-01",
2721
"privacy": {
@@ -70,15 +64,12 @@ def test_adapater(settings):
7064
assert setting_platform_name == CONFIGS['configuration']['setting']['PLATFORM_NAME']
7165
assert adapter.get_value_of_type('secret', 'SEGMENT_KEY', None) == 'so secret'
7266

73-
css_vars = adapter.get_amc_v1_theme_css_variables()
74-
# This change is temporary til we migrate off AMC and its edx-customers-theme
75-
assert css_vars == [
76-
["selected_font", ["lato", "lato"]],
77-
["text_color", ["#0a0a0a", "#0a0a0a"]],
78-
["header_logo_height", ["110", "110"]],
79-
["header_buttons_color", ["#164be0", "#164be0"]],
80-
["header_font_size", ["17", "17"]],
81-
], 'get_amc_v1_theme_css_variables should return AMC-like variables'
67+
css_vars = adapter.get_css_variables_dict()
68+
assert css_vars == {
69+
"selected_font": "lato",
70+
"text_color": "#0a0a0a",
71+
"header_logo_height": "110",
72+
}, 'get_css_variables_dict returns a dictionary of all variables'
8273

8374
privacy_page_vars = adapter.get_value_of_type('page', 'privacy', None)
8475
assert privacy_page_vars == CONFIGS['configuration']['page']['privacy']

0 commit comments

Comments
 (0)