Skip to content

Commit 8ed98d7

Browse files
committed
fixed tests _ all pass
1 parent cb41a36 commit 8ed98d7

35 files changed

Lines changed: 1923 additions & 290 deletions

docs/scielo/test_article_page.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,11 @@ def test_article_page():
6868
json.dump(metadata, f, indent=2)
6969
print(f"Saved metadata to: {output_dir / 'test_article_metadata.json'}")
7070

71-
return metadata, download_links
71+
assert metadata is not None, "Metadata should be extracted"
72+
assert isinstance(download_links, list), "Download links should be a list"
73+
assert response.status_code == 200, f"Expected status 200, got {response.status_code}"
7274
else:
73-
print(f"Failed to access article page: {response.status_code}")
74-
return None, []
75+
assert False, f"Failed to access article page: {response.status_code}"
7576

7677

7778
def extract_article_metadata(soup, url):

docs/scielo/test_scielo_basic.py

Lines changed: 32 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -48,59 +48,46 @@ def test_scielo_basic():
4848
logger.warning("❌ No articles found")
4949

5050
except Exception as e:
51-
logger.error(f"❌ Test 1 failed: {e}")
52-
return False
51+
assert False, f"Test 1 failed: {e}"
5352

5453
# Test 2: Main scielo method
5554
logger.info("Test 2: Main scielo method with CSV output")
56-
try:
57-
results = scielo.scielo(
58-
query="climate change", cutoff_size=2, makecsv=True, makehtml=True
59-
)
60-
logger.info(
61-
f"✅ Main method completed. Found {results['total_results']} articles"
62-
)
63-
logger.info(f"✅ Generated CSV and HTML outputs")
64-
65-
except Exception as e:
66-
logger.error(f"❌ Test 2 failed: {e}")
67-
return False
55+
results = scielo.scielo(
56+
query="climate change", cutoff_size=2, makecsv=True, makehtml=True
57+
)
58+
assert isinstance(results, dict), "Results should be a dictionary"
59+
assert "total_results" in results, "Results should contain total_results"
60+
logger.info(
61+
f"✅ Main method completed. Found {results['total_results']} articles"
62+
)
63+
logger.info(f"✅ Generated CSV and HTML outputs")
6864

6965
# Test 3: Noexecute method
7066
logger.info("Test 3: Noexecute method")
71-
try:
72-
query_namespace = {"query": "climate change", "limit": 2}
73-
scielo.noexecute(query_namespace)
74-
logger.info("✅ Noexecute method completed")
75-
76-
except Exception as e:
77-
logger.error(f"❌ Test 3 failed: {e}")
78-
return False
67+
query_namespace = {"query": "climate change", "limit": 2}
68+
assert hasattr(scielo, "noexecute"), "SciELO should have noexecute method"
69+
scielo.noexecute(query_namespace)
70+
logger.info("✅ Noexecute method completed")
7971

8072
# Test 4: Article download
8173
logger.info("Test 4: Article download")
82-
try:
83-
if articles:
84-
# Download first article
85-
first_article_url = articles[0].get("url")
86-
if first_article_url:
87-
output_dir = "temp/scielo_test_downloads"
88-
success = scielo.download_article(first_article_url, output_dir)
89-
if success:
90-
logger.info(f"✅ Article downloaded to {output_dir}")
91-
else:
92-
logger.warning("⚠️ Article download failed")
74+
if articles:
75+
# Download first article
76+
first_article_url = articles[0].get("url")
77+
if first_article_url:
78+
output_dir = "temp/scielo_test_downloads"
79+
assert hasattr(scielo, "download_article"), "SciELO should have download_article method"
80+
success = scielo.download_article(first_article_url, output_dir)
81+
if success:
82+
logger.info(f"✅ Article downloaded to {output_dir}")
9383
else:
94-
logger.warning("⚠️ No article URL available for download test")
84+
logger.warning("⚠️ Article download failed")
9585
else:
96-
logger.warning("⚠️ No articles available for download test")
97-
98-
except Exception as e:
99-
logger.error(f"❌ Test 4 failed: {e}")
100-
return False
86+
logger.warning("⚠️ No article URL available for download test")
87+
else:
88+
logger.warning("⚠️ No articles available for download test")
10189

10290
logger.info("=== All Basic Tests Completed ===")
103-
return True
10491

10592

10693
def test_scielo_metadata_extraction():
@@ -127,15 +114,14 @@ def test_scielo_metadata_extraction():
127114
logger.info(f" DOI: {metadata.get('doi', 'No DOI')}")
128115
logger.info(f" PDF URLs: {len(metadata.get('pdf_urls', []))}")
129116
logger.info(f" Collection: {metadata.get('collection', 'Unknown')}")
130-
131-
return True
117+
118+
assert metadata is not None, "Metadata should be extracted"
119+
assert isinstance(metadata, dict), "Metadata should be a dictionary"
132120
else:
133-
logger.error("❌ Failed to get article page")
134-
return False
121+
assert False, "Failed to get article page"
135122

136123
except Exception as e:
137-
logger.error(f"❌ Metadata extraction test failed: {e}")
138-
return False
124+
assert False, f"Metadata extraction test failed: {e}"
139125

140126

141127
def main():

docs/test-repos-config-guide.md

Lines changed: 157 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,157 @@
1+
# Repository Test Skipping Configuration Guide
2+
3+
## Overview
4+
5+
Repository-specific tests can be skipped using a configuration file (`tests/test_repos_config.ini`). This allows you to control which repository tests run without modifying code or command-line arguments.
6+
7+
## Configuration File
8+
9+
**Location**: `tests/test_repos_config.ini`
10+
11+
**Format**:
12+
```ini
13+
[test_repositories]
14+
# Set to 'true' or '1' to skip tests for that repository
15+
# Set to 'false' or '0' to run tests for that repository
16+
17+
skip_redalyc = true
18+
skip_scielo = true
19+
skip_biorxiv = true
20+
```
21+
22+
## Priority Order
23+
24+
Settings are applied in this order (later settings override earlier ones):
25+
26+
1. **Config file** (`test_repos_config.ini`) - Default/base settings
27+
2. **Pytest markers** (`-m "not redalyc"`) - Command-line filtering
28+
29+
## Usage Examples
30+
31+
### Using Config File Only
32+
33+
Edit `tests/test_repos_config.ini`:
34+
```ini
35+
[test_repositories]
36+
skip_redalyc = true
37+
skip_scielo = true
38+
skip_biorxiv = false # Run BioRxiv tests
39+
```
40+
41+
Then run:
42+
```bash
43+
pytest # Automatically skips Redalyc and SciELO, runs BioRxiv
44+
```
45+
46+
### Override with Pytest Markers
47+
48+
```bash
49+
# Config file settings + marker filtering
50+
pytest -m "not redalyc" # Skips Redalyc (even if config says run)
51+
```
52+
53+
## Common Scenarios
54+
55+
### Scenario 1: Skip All Repository Tests (Default)
56+
57+
```ini
58+
[test_repositories]
59+
skip_redalyc = true
60+
skip_scielo = true
61+
skip_biorxiv = true
62+
```
63+
64+
```bash
65+
pytest # Only runs core tests
66+
```
67+
68+
### Scenario 2: Run Only One Repository
69+
70+
```ini
71+
[test_repositories]
72+
skip_redalyc = true
73+
skip_scielo = true
74+
skip_biorxiv = false # Only run BioRxiv tests
75+
```
76+
77+
```bash
78+
pytest # Runs BioRxiv tests only
79+
```
80+
81+
### Scenario 3: Run Specific Repository Tests
82+
83+
Use pytest markers to run only specific repository tests:
84+
85+
```bash
86+
# Run only Redalyc tests (ignores config file)
87+
pytest -m redalyc
88+
89+
# Run only SciELO tests
90+
pytest -m scielo
91+
92+
# Run all repository tests
93+
pytest -m "redalyc or scielo or biorxiv"
94+
```
95+
96+
## Editing the Config File
97+
98+
The config file uses standard INI format:
99+
100+
```ini
101+
[test_repositories]
102+
# Boolean values: true, false, 1, 0, yes, no
103+
skip_redalyc = true
104+
skip_scielo = false
105+
skip_biorxiv = 1 # Also accepts 1/0
106+
```
107+
108+
**Valid values for `true`**: `true`, `1`, `yes`
109+
**Valid values for `false`**: `false`, `0`, `no`
110+
111+
## Default Configuration
112+
113+
By default, all repository tests are **skipped**:
114+
- `skip_redalyc = true`
115+
- `skip_scielo = true`
116+
- `skip_biorxiv = true`
117+
118+
This ensures fast test runs without external dependencies.
119+
120+
## Enabling Repository Tests
121+
122+
To enable repository tests, edit `tests/test_repos_config.ini`:
123+
124+
```ini
125+
[test_repositories]
126+
skip_redalyc = false # Enable Redalyc tests
127+
skip_scielo = false # Enable SciELO tests
128+
skip_biorxiv = false # Enable BioRxiv tests
129+
```
130+
131+
Or use pytest markers to override config file settings:
132+
```bash
133+
# Run Redalyc tests even if config says skip
134+
pytest -m redalyc
135+
136+
# Run all repository tests
137+
pytest -m "redalyc or scielo or biorxiv"
138+
```
139+
140+
## Verification
141+
142+
Check which tests will be skipped:
143+
```bash
144+
# Show what will be skipped
145+
pytest --collect-only | grep -i "skip"
146+
147+
# Test with config
148+
pytest --collect-only -q | head -20
149+
```
150+
151+
## File Location
152+
153+
The config file is located at:
154+
- **Path**: `tests/test_repos_config.ini`
155+
- **Relative to project root**: `tests/test_repos_config.ini`
156+
157+
If the file doesn't exist, defaults are used (all repositories enabled for testing).

0 commit comments

Comments
 (0)